Associative containers support efficient lookup and retrieval by a key.
the ordered containers—map, multimap, set, and multiset—the key type must define a way to compare the elements.
Callable objects passed to a sort algorithm (§ 10.3.1, p. 386) must meet the same requirements as do the keys in an associative container.
To use our own operation, we must define the multiset with two types: the key type, and the comparison type, which is a function pointer type that can point to compare function.
the data members of pair are public ,These members are named first and second,respectively. We access these members using the normal member access notation.
It is essential to remember that the value_type of a map is a pair and that we can change the value but not the key member of that pair.
Iterators for sets Are const,the keys in a set are also const.
The output of this program is in alphabetical order. When we use an iterator to traverse a map, multimap, set, or multiset, the iterators yield elements in ascending key order.
The insert members (Table 11.4 (overleaf)) add one element or a range of elements.
Erasing Elements
c.erase(k) remove every element with the key k from c.
c.erase(p) remove the element denoted by the iterater p from c.
c.erase(b,e) remove the element in the range demoted by b and e and return e.
The map and unordered_map containers provide the subscript operator and a
corresponding at function,We cannot subscript a multimap or an unordered_multimap because there may be more than one value associated with a given key.
Subscripting a map behaves quite differently from subscripting an array or vector: Using a key that is not already present adds an element with that key to the map.
Operations to Find Elements in an Associative Container
c.find(k) return iterator to the first element with the key k or the off-the-end iterator.
c.count(k) return the number of elements with key k.
c.lower_bound(k) return an iterator to the first element with key not less than k.
c.upper_bound(k) return an iterator to the first element with key greater than k.
c.equal_range(k) return a pair of iterator denoting the elements with key k,if k is not present, both menbers are c.end().
If the key is present, then the first iterator refers to the first instance of the key and the second iterator refers one past the last instance of the key. If no matching element is found, then both the first and second iterators refer to the position where this key can be inserted.
For the map and unordered_map types,using a subscript has an important side effect: If that key is not already in the map, then subscript inserts an element with that key.
When a multimap or multiset has multiple elements of a given key, those elements will be adjacent within the container.
Hash and Unordermap???